package com.wan.net.rpc.handler;

import com.wan.net.core.packet.Packet;
import com.wan.net.handler.client.AbstractClientChannelHandler;
import com.wan.net.rpc.invoker.callback.CallbackManager;
import com.wan.net.rpc.message.RpcResponse;
import com.wan.util.serializer.ProtoStuffSerializer;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author wwh
 * @date 2022/6/22 10:36
 */
public class RpcClientHandler extends AbstractClientChannelHandler {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Packet packet) throws Exception {
        int messageId = packet.getMessageId();
        RpcResponse response = ProtoStuffSerializer.decode(packet.getContent(), RpcResponse.class);
        CallbackManager.callback(messageId,response);
    }
}
